package cn.itsource.feign.client;

import cn.itsource.feign.fallback.RedisFeignClientFallbackFactory;
import cn.itsource.hrm.utils.AjaxResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

//调用缓存服务的feign接口  后面写托底方法 ，自己定义
@Component
@FeignClient(value = "CACHE-SERVER",fallbackFactory = RedisFeignClientFallbackFactory.class)  //服务名不区分大小写
public interface RedisFeignClient {
    //@RequestParam("key"):从请求参数中获取名字为key和value的数据
    @RequestMapping(value = "/redis/set",method = RequestMethod.POST)
    AjaxResult set(@RequestParam("key") String key , @RequestParam("value")String value);


    @RequestMapping(value = "/redis/setex",method = RequestMethod.POST)
    AjaxResult setex(@RequestParam("key") String key,
                            @RequestParam("seconds") int seconds ,
                            @RequestParam("value")String value);


    //@PathVariable("key") :从 url路径中获取名字为key的数据
    @RequestMapping(value = "/redis/get/{key}",method = RequestMethod.GET)
    AjaxResult get(@PathVariable("key") String key);



}
